import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:proj_sfv/pages/UserDetail2.dart';
import 'package:proj_sfv/pages/userDetailPage.dart';
import 'package:proj_sfv/store/MyArguments.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';

class FriendPage2 extends StatefulWidget{


  @override
  State<FriendPage2> createState() => _FriendPage2State();

  const FriendPage2();
  
}

class _FriendPage2State extends State<FriendPage2> {
  String _token;
  int _id;

  @override
  void initState() {
    SharedPreferences.getInstance().then((value) {
      _token = value.getString("token");
      _id = value.getInt("id");
      if (_token == null) {
        Fluttertoast.showToast(msg: "请先登陆！", webShowClose: true);
      }
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: TIMUIKitContact(
        topList: [
          TopListItem(name: "好友请求", id: "friendRequests", icon: TIMUIKitUnreadCount(), onTap: () {
            Navigator.pushNamed(context, "/user/friend/requests", arguments: MyArguments(_id, _token));
          }),
        ],
        isShowOnlineStatus: true,
        onTapItem: (item) {
          Navigator.push(context, MaterialPageRoute(
              builder: (context) => UserDetailsPage2(int.parse(item.userID), _token, _id),
          ));
        },
        emptyBuilder: (context) => Center(
          child: Text("无联系人"),
        ),
      ),
    );
  }

  void refresh() {
    setState(() {
    });
  }
}